package com.hqyj.ctxp.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Value("${upload.find.file.path}")
    private String uploadFindFilePath;  //图片存储路径
    @Value("${upload.file.path}") //图片映射路径
    private String uploadFilePath;

    //配置映射路径

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 访问地址 /images/** 就到磁盘D:/images/ 找
        registry.addResourceHandler(uploadFindFilePath).
                addResourceLocations("file:"+uploadFilePath);
    }
}
